package com.studentrecipe.controller;

import com.studentrecipe.mapper.MapperLogin;
import com.studentrecipe.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
public class ControllerLogin {

    @Autowired
    private MapperLogin mapperLogin;

    @RequestMapping("/login")
    public Result login(String username, String password) {

        if(mapperLogin.login(username, password)!=null){
            return Result.success(mapperLogin.login(username, password));
        }
        else{
            return Result.fail("Account or Password Error");
        }

    }

}
